package com.ruoyi.web.controller.system;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.base.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.page.TableDataInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.base.BaseController;
import com.ruoyi.system.domain.WdyEthTxn;
import com.ruoyi.system.service.IWdyEthTxnService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * eth交易 信息操作处理
 * 
 * @author ruoyi
 * @date 2020-02-25
 */
@Controller
@RequestMapping("/system/wdyEthTxn")
public class WdyEthTxnController extends BaseController
{
    private String prefix = "system/wdyEthTxn";
	
	@Autowired
	private IWdyEthTxnService wdyEthTxnService;
	
	@RequiresPermissions("system:wdyEthTxn:view")
	@GetMapping()
	public String wdyEthTxn()
	{
	    return prefix + "/wdyEthTxn";
	}
	
	/**
	 * 查询eth交易列表
	 */
	@RequiresPermissions("system:wdyEthTxn:list")
	@PostMapping("/list")
	@ResponseBody
	public TableDataInfo list(WdyEthTxn wdyEthTxn)
	{
		startPage();
        List<WdyEthTxn> list = wdyEthTxnService.selectWdyEthTxnList(wdyEthTxn);
		return getDataTable(list);
	}
	
	
	/**
	 * 导出eth交易列表
	 */
	@RequiresPermissions("system:wdyEthTxn:export")
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(WdyEthTxn wdyEthTxn)
    {
    	List<WdyEthTxn> list = wdyEthTxnService.selectWdyEthTxnList(wdyEthTxn);
        ExcelUtil<WdyEthTxn> util = new ExcelUtil<WdyEthTxn>(WdyEthTxn.class);
        return util.exportExcel(list, "wdyEthTxn");
    }
	
	/**
	 * 新增eth交易
	 */
	@GetMapping("/add")
	public String add()
	{
	    return prefix + "/add";
	}
	
	/**
	 * 新增保存eth交易
	 */
	@RequiresPermissions("system:wdyEthTxn:add")
	@Log(title = "eth交易", businessType = BusinessType.INSERT)
	@PostMapping("/add")
	@ResponseBody
	public AjaxResult addSave(WdyEthTxn wdyEthTxn)
	{		
		return toAjax(wdyEthTxnService.insertWdyEthTxn(wdyEthTxn));
	}

	/**
	 * 修改eth交易
	 */
	@GetMapping("/edit/{id}")
	public String edit(@PathVariable("id") Long id, ModelMap mmap)
	{
		WdyEthTxn wdyEthTxn = wdyEthTxnService.selectWdyEthTxnById(id);
		mmap.put("wdyEthTxn", wdyEthTxn);
	    return prefix + "/edit";
	}
	
	/**
	 * 修改保存eth交易
	 */
	@RequiresPermissions("system:wdyEthTxn:edit")
	@Log(title = "eth交易", businessType = BusinessType.UPDATE)
	@PostMapping("/edit")
	@ResponseBody
	public AjaxResult editSave(WdyEthTxn wdyEthTxn)
	{		
		return toAjax(wdyEthTxnService.updateWdyEthTxn(wdyEthTxn));
	}
	
	/**
	 * 删除eth交易
	 */
	@RequiresPermissions("system:wdyEthTxn:remove")
	@Log(title = "eth交易", businessType = BusinessType.DELETE)
	@PostMapping( "/remove")
	@ResponseBody
	public AjaxResult remove(String ids)
	{		
		return toAjax(wdyEthTxnService.deleteWdyEthTxnByIds(ids));
	}
	
}
